using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using Castle.MonoRail.Framework;
using Castle.MonoRail.ActiveRecordSupport;
using Saffron.Filters;
using Saffron.Framework.Messages;
using Saffron.Framework.Projects;
using Saffron.Framework.Users;
namespace Saffron.Controllers
{

    [Layout("default"), Rescue("generalerror")]
    [Filter(ExecuteEnum.BeforeAction, typeof(AuthenticationFilter))]
    public class MessageController:PublicBaseController 
    {
        /// <summary>
        /// The user accounts view page
        /// </summary>
        public void Index()
        {
            
            MessageInfo [] messageinfolist = MessageInfo.FindMessageInfoListByUser(CurrentUser);
                List<Message> messages = new List<Message>();
                foreach (MessageInfo info in messageinfolist)
                {
                    messages.Add(info.SentMessage);
                }

                PropertyBag["messages"] = messages;

        }
        public void View()
        {
            if (Query["id"] == null)
            {
                RenderView("Denied");
            }   
                PropertyBag["Message"] =  (Message)Message.FindMessageById(Int32.Parse(Query["id"]));
           
        }
        public void Create()
        {

        }

        [AjaxAction]
        public void SenToList()
        {

        }
        public void Denied()
        {

        }
    }
}
